import request from '@/utils/request'

// 查询灵感列表
export function listInspiration(query) {
  return request({
    url: '/api/inspiration/list',
    method: 'get',
    params: query
  })
}


// 新增灵感
export function addInspiration(data) {
  //form-data格式
  return request({
    url: '/api/inspiration/add',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 修改灵感
export function updateInspiration(data) {
  //form-data格式
  return request({
    url: '/api/inspiration/edit',
    method: 'put',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 删除灵感
export function delInspiration(id) {
  return request({
    url: '/api/inspiration/remove/' + id,
    method: 'delete'
  })
}

// 查询灵感详细
export function getInspiration(id) {
  return request({
    url: '/api/inspiration/getInfo/' + id,
    method: 'get'
  })
}

//保存灵感关联的SKU  
export function addInspirationSku(data) {
  let params = {
    inspirationId: data.inspirationId,
    skuIds: data.skuIds,
  }
  return request({
    url: `/api/inspiration/${params.inspirationId}/skus`,
    method: 'post',
    data: params.skuIds,
  })
}
//通过inspirationId和删除skuId关联的商品sku
export function delInspirationSku(data) {
  let body = {
    inspirationId: data.inspirationId,
    skuIds: data.skuIds,
  }
  return request({
    url: `/api/inspiration/${body.inspirationId}/skus`,
    method: 'delete',
    data: body.skuIds,
  })
}


